{{include file="public/header" /}}

<!-- conntent start  -->
<div class="am-padding-sm">
    <!-- form start -->
    <form class="am-form form-validation am-form-full-screen am-form-popup-fixed" method="post" action="{{:MyUrl('index/useraddress/save')}}" request-type="ajax-reload" request-value="parent">
        <div class="am-cf">
            <div class="am-u-sm-8 am-padding-horizontal-0">
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_name')}}<span class="am-form-group-label-tips-must">*</span></label>
                    <input type="text" name="name" placeholder="{{:MyLang('common_service.useraddress.form_item_name_message')}}" minlength="2" maxlength="30" data-validation-message="{{:MyLang('common_service.useraddress.form_item_name_message')}}" class="am-radius" {{if !empty($data['name'])}} value="{{$data.name}}"{{/if}} required />
                </div>
            </div>
            <div class="am-u-sm-4 am-padding-horizontal-0">
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_alias')}}</label>
                    <input type="text" name="alias" placeholder="{{:MyLang('common_service.useraddress.form_item_alias_message')}}" minlength="0" maxlength="16" data-validation-message="{{:MyLang('common_service.useraddress.form_item_alias_message')}}" class="am-radius" {{if !empty($data['alias'])}} value="{{$data.alias}}"{{/if}} />
                </div>
            </div>
        </div>

        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_tel')}}<span class="am-form-group-label-tips-must">*</span></label>
            <input type="text" name="tel" placeholder="{{:MyLang('common_service.useraddress.form_item_tel')}}" minlength="6" maxlength="30" data-validation-message="{{:MyLang('common_service.useraddress.form_item_tel_message')}}" class="am-radius" {{if !empty($data['tel'])}} value="{{$data.tel}}"{{/if}} required />
        </div>

        {{include file="lib/region_linkage" /}}
        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_address')}}<span class="am-form-group-label-tips-must">*</span></label>
            {{if MyC('home_user_address_map_status') eq 1}}
                <div class="am-input-group am-input-group-sm">
                    <input type="hidden" name="lng" id="form-lng" {{if !empty($data['lng'])}} value="{{$data.lng}}"{{/if}} />
                    <input type="hidden" name="lat" id="form-lat" {{if !empty($data['lat'])}} value="{{$data.lat}}"{{/if}} />
                    <input type="text" name="address" id="form-address" placeholder="{{:MyLang('common_service.useraddress.form_item_address_message')}}" minlength="2" maxlength="80" data-validation-message="{{:MyLang('common_service.useraddress.form_item_address_message')}}" class="am-radius am-form-field" {{if !empty($data['address'])}} value="{{$data.address}}"{{/if}} required />
                    <span class="am-input-group-btn">
                        <button type="button" class="am-btn am-btn-default am-radius" id="map-location-submit">
                            <i class="am-icon-map-marker"></i>
                            <span>{{:MyLang('location_title')}}</span>
                        </button>
                    </span>
                </div>
                <div id="map" data-level="17" class="am-margin-top-xs"></div>
            {{else /}}
                <input type="text" name="address" id="form-address" placeholder="{{:MyLang('common_service.useraddress.form_item_address_message')}}" minlength="2" maxlength="80" data-validation-message="{{:MyLang('common_service.useraddress.form_item_address_message')}}" class="am-radius" {{if !empty($data['address'])}} value="{{$data.address}}"{{/if}} required />
            {{/if}}
        </div>

        <div class="am-form-group">
            <label class="am-block">{{:MyLang('form_is_default_title')}}</label>
            <input name="is_default" value="1" type="checkbox" data-off-text="{{:MyLang('no_title')}}" data-on-text="{{:MyLang('yes_title')}}" data-size="xs" data-on-color="success" data-off-color="default" data-handle-width="49" data-am-switch {{if isset($data['is_default']) and $data['is_default'] eq 1}}checked="true"{{/if}} />
        </div>
        {{if MyC('home_user_address_idcard_status') eq 1}}
            <div class="am-alert am-alert-secondary">
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_name')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_name_tips')}}</span></label>
                    <input type="text" name="idcard_name" placeholder="{{:MyLang('common_service.useraddress.form_item_idcard_name')}}" minlength="0" maxlength="30" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_name_message')}}" class="am-radius" {{if !empty($data['idcard_name'])}} value="{{$data.idcard_name}}"{{/if}} />
                </div>
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_number')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_number_tips')}}</span></label>
                    <input type="text" name="idcard_number" placeholder="{{:MyLang('common_service.useraddress.form_item_idcard_number')}}" minlength="0" maxlength="18" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_number_message')}}" class="am-radius" {{if !empty($data['idcard_number'])}} value="{{$data.idcard_number}}"{{/if}} />
                </div>
                <div class="am-form-group plug-file-upload-view">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_images')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_images_tips')}}</span></label>
                    <div class="am-nbfc user-address-idcard-images">
                        <div class="am-fl">
                            <ul class="plug-file-upload-view images-idcard_front" data-form-name="idcard_front" data-max-number="1" data-dialog-type="images">
                                <li>
                                    {{if !empty($data['idcard_front_old'])}}
                                        <input type="text" name="idcard_front" value="{{$data.idcard_front_old}}" />
                                    {{/if}}
                                    <img src="{{if empty($data['idcard_front'])}}{{$attachment_host}}/static/common/images/default-idcard-front.jpg{{else /}}{{$data.idcard_front}}{{/if}}" />
                                    <i>×</i>
                                </li>
                            </ul>
                            <div class="plug-file-upload-submit" data-view-tag="ul.images-idcard_front">+{{:MyLang('common_service.useraddress.form_item_idcard_front_button_name')}}</div>
                        </div>
                        <div class="am-fl am-margin-left-lg">
                            <ul class="plug-file-upload-view images-idcard_back" data-form-name="idcard_back" data-max-number="1" data-dialog-type="images">
                                <li>
                                    {{if !empty($data['idcard_back_old'])}}
                                        <input type="text" name="idcard_back" value="{{$data.idcard_back_old}}" />
                                    {{/if}}
                                    <img src="{{if empty($data['idcard_back'])}}{{$attachment_host}}/static/common/images/default-idcard-back.jpg{{else /}}{{$data.idcard_back}}{{/if}}" />
                                    <i>×</i>
                                </li>
                            </ul>
                            <div class="plug-file-upload-submit" data-view-tag="ul.images-idcard_back">+{{:MyLang('common_service.useraddress.form_item_idcard_back_button_name')}}</div>
                        </div>
                    </div>
                </div>
            </div>
        {{/if}}

        <div class="am-form-popup-submit">
            <input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
            <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'{{:MyLang('processing_tips')}}'}">{{:MyLang('save_title')}}</button>
        </div>
    </form>
    <!-- form end -->
</div>
<!-- conntent end  -->

<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

<script type="text/javascript">
$(function()
{
    {{if MyC('home_user_address_map_status') eq 1}}
        // 百度地图初始化
        MapInit({{if !empty($data['lng'])}}{{$data['lng']}}{{else /}}116.400244{{/if}},{{if !empty($data['lat'])}}{{$data['lat']}}{{else /}}39.92556{{/if}});
    {{/if}}
});
</script>